import request from '../utils/request'

export const prefix = ''

export function generateBaseApi(basePath) {
  return {
    page: () => {
      return request(`${basePath}`, {
        method: 'GET',
      })
    },

    getById: (id) => {
      return request(`${basePath}/${id}`, {
        method: 'GET',
      })
    },

    save: (payload) => {
      return request(`${basePath}`, {
        method: 'POST',
        body: payload,
      })
    },

    update: (payload) => {
      return request(`${basePath}/${payload.id}`, {
        method: 'PUT',
        body: payload,
      })
    },

    delete: (id) => {
      return request(`${basePath}/${id}`, {
        method: 'DELETE',
      })
    },
  }
}
